}
pub struct Context<'a, 'cfg: 'a> {
+ pub ws: &'a Workspace<'cfg>,
pub config: &'cfg Config,
pub resolve: &'a Resolve,
- pub current_package: Option<PackageId>,
pub compilation: Compilation<'cfg>,
pub packages: &'a PackageSet<'cfg>,
pub build_state: Arc<BuildState>,
pub struct Metadata(u64);
impl<'a, 'cfg> Context<'a, 'cfg> {
- pub fn new(ws: &Workspace<'cfg>,
+ pub fn new(ws: &'a Workspace<'cfg>,
resolve: &'a Resolve,
packages: &'a PackageSet<'cfg>,
config: &'cfg Config,
None => None,
};
- let current_package = ws.current_opt().map(Package::package_id).cloned();
Ok(Context {
+ ws: ws,
host: host_layout,
target: target_layout,
resolve: resolve,
- current_package: current_package,
packages: packages,
config: config,
target_info: TargetInfo::default(),
// we don't want to link it up.
if src_dir.ends_with("deps") {
// Don't lift up library dependencies
- if self.current_package.as_ref().map_or(false, |p| unit.pkg.package_id() != p)
- && !unit.target.is_bin() {
+ if self.ws.current_opt().map_or(false, |p| unit.pkg.package_id() != p.package_id())
+ && !unit.target.is_bin() {
None
} else {
Some((
}
pub fn show_warnings(&self, pkg: &PackageId) -> bool {
- self.current_package.as_ref().map_or(false, |p| *pkg == *p)
+ self.ws.current_opt().map_or(false, |p| *pkg == *p.package_id())
|| pkg.source_id().is_path()
|| self.config.extra_verbose()
}
}
let build_type = if self.is_release { "release" } else { "debug" };
- let profile = cx.current_package.as_ref().map_or_else(Profile::default, |p| {
- cx.lib_profile(p).to_owned()
+ let profile = cx.ws.current_opt().map_or_else(Profile::default, |p| {
+ cx.lib_profile(p.package_id()).to_owned()
});
let mut opt_type = String::from(if profile.opt_level == "0" { "unoptimized" }
else { "optimized" });
let prefer_dynamic = (unit.target.for_host() &&
!unit.target.is_custom_build()) ||
(crate_types.contains(&"dylib") &&
- cx.current_package.as_ref().map_or(false, |p| {
- *p != *unit.pkg.package_id()
+ cx.ws.current_opt().map_or(false, |p| {
+ *p.package_id() != *unit.pkg.package_id()
}));
if prefer_dynamic {
cmd.arg("-C").arg("prefer-dynamic");